<template>
	<view v-if="pageShow">
		<!-- 拉黑弹出款 -->
		<u-popup :show="lhshow" @close="lhclose" mode="center" :round="10">
			<view class="" style="padding: 30rpx 30rpx;">
				<view class="bigtext fonweight xiaohei" style="width: 550rpx;">
					拉黑后，对方将无法搜索到你，也不能再给你发私信，也不能看到发布的作品
				</view>
				<view class=" flexright" style="margin-top: 100rpx;">
					<view class="xiaohui sanshier margin_right3" @click="lhclose">取消</view>
					<view class="xiaolan sanshier fonweight" @click="lahei(listid)">确定</view>
				</view>
			</view>
		</u-popup>
		<!-- 投诉拉黑弹框 -->
		<u-popup :show="show" @close="close">
			<view class="mainpadding">
				<view class="flexbetween">
					<view class="xiaohei sanshier ">{{dataAll.nickname}}</view>
					<view class="" @click="close">
						<u-icon name="close"></u-icon>
					</view>
				</view>
				<view class="flexleft margin_top2" @click="copy(dataAll.idno)">
					<view class="xiaohui strongtext margin_right1">ID号:{{dataAll.idno}}</view>
					<image class="fuzhi" src="../static/image/system/fz.png" mode=""></image>
				</view>
				<view class="flexleft margin_top">
					<view class="" @click="jumper('/pages_homepage/jubao');close()">
						<view class="wbox " style="margin: auto;">
							<u-icon name="error-circle-fill" size="22"></u-icon>
						</view>
						<view class="strongtext xiaohei margin_top1 textcenter">举报</view>
					</view>
					<view class="" style="margin-left: 40rpx;" @click="dklh" v-if="dataAll.is_black==0">
						<view class="wbox">
							<u-icon name="close-circle-fill" size="22"></u-icon>
						</view>
						<view class="strongtext xiaohei margin_top1 textcenter">拉黑</view>
						
					</view>
					<view class="" style="margin-left: 40rpx;" @click="lahei(listid)" v-if="dataAll.is_black==1">
						<view class="wbox">
							<u-icon name="close-circle-fill" size="22"></u-icon>
						</view>
						<view class="strongtext xiaohei margin_top1 textcenter">解除拉黑</view>
					</view>
				</view>
			</view>
		</u-popup>
		<!-- 头部 -->
		<view class="toubox dingwei">
			<view class="zuytu">
				<image src="../static/image/system/zybjt.png" mode=""></image>
			</view>
			<view class="flexbetween dingbu">
				<view class="" @click="fhsyy">
					<image class="dbicon" src="../static/image/system/fh.png" mode=""></image>
				</view>
				<view class="" @click="show = true">
					<image class="dbicon" src="../static/image/system/sd.png" mode=""></image>
				</view>
			</view>
		</view>
		<!-- 滚动头部 -->
		<view class="nav" :style="'background-color: rgba(255, 255, 255,' + op +')'" v-if="op==1">
			<view class="status-bar" :style="'height:' + statusBarHeight + 'px'"></view>
			<view class="mainpadding2 flexbetween" :style="'color: rgba(0, 0, 0,' + op +')'">
				<u-icon name="arrow-left" color="#333" size="22" v-if="op==1" @click="fhsyy"></u-icon>
				<view class="" style="width: 28rpx;" v-else></view>
				<view class="sanshier hei_text bold">{{dataAll.nickname}}</view>
				<view class="" style="width: 28rpx;"></view>
			</view>
		</view>
		<view class="baibox mainpadding">
			<view class="flexleft">
				<image class="touxiang margin_right3" :src="dataAll.avatar_text" mode="" @click="lbtpriview(0,[dataAll.avatar_text])"></image>
				<view class="labtn flexcenter margin_right2" v-if="dataAll.is_gz==0 && listid!=user_id" @click="guanzhufn(listid,dataAll)">
					<view class="margin_right1">
						<u-icon name="plus" color="#fff" size="14"></u-icon>
					</view>
					<view class="ershiba xiaobai">关注</view>
				</view>

				<view class="dhbtn ershiba xiaohei margin_right2" v-if="dataAll.is_gz==1 && listid!=user_id"
					@click="cancelguanzhufn(listid,dataAll)">取消关注</view>
				<view class="dhbtn ershiba xiaohei" @click="sixin()" v-if="listid!=user_id && dataAll.is_black==0">私信</view>
			</view>
			<view class=" margin_top xiahuaxian">
				<view class="flexleft">
					<view class="xiaohei fonweight margin_right2" style="font-size: 48rpx;">{{dataAll.nickname}}</view>
					<u-icon name="checkmark-circle-fill" color="#ff0000" size="20"
						v-if="dataAll.is_plg"></u-icon>
					<!-- <view class="xlbtn xiaolan smalltext margin_right1 flexcenter" v-if="dataAll.online==1">在线</view>
					<view class="xhuibtn xiaohui smalltext margin_right1 flexcenter" v-if="dataAll.online==0">离线</view> -->
					<!-- <view class="xlbtn xiaolan smalltext margin_right1 flexcenter" v-if="dataAll.is_plg">陪聊官</view> -->
				</view>
				<view class="flexleft margin_top2" @click="copy(dataAll.idno)">
					<view class="xiaohui strongtext margin_right1">ID号:{{dataAll.idno}}</view>
					<image class="fuzhi" src="../static/image/system/fz.png" mode=""></image>
				</view>
				<view class="margin_top ershiba xiaohui" v-if="dataAll.bio">{{dataAll.bio}}</view>
				<view class="margin_top ershiba xiaohui" v-else>这个人很懒，什么也没留下！</view>
				<view class="flexleft margin_top flex_wrap">
					<view class="xhbtn flexcenter">
						<image class="zhixiang margin_right1" src="../static/image/system/zx.png" mode=""></image>
						<view class="smalltext xiaohui">{{dataAll.age}}岁</view>
					</view>
					<view class="xhbtn flexcenter margin_left1" v-for="(item,index) in dataAll.user_flag_names">
						<view class="smalltext xiaohui" :key="index">{{item}}</view>
					</view>
				</view>
				<view class="flexleft margin_top">
					<view class="flexleft margin_right2">
						<view class="sanshier fonweight margin_right1">{{dataAll.dz_num}}</view>
						<view class="smalltext xiaohui margin_right1">获赞</view>
					</view>
					<view class="flexleft margin_right2" @click="tzgywm(0)" v-if="dataAll.gz_open==2">
						<view class="sanshier fonweight margin_right1">{{dataAll.mygz_num}}</view>
						<view class="smalltext xiaohui margin_right1">关注</view>
					</view>
					<view class="flexleft" @click="tzgywm(1)" v-if="dataAll.fs_open==2">
						<view class="sanshier fonweight margin_right1">{{dataAll.myfs_num}}</view>
						<view class="smalltext xiaohui margin_right1">粉丝</view>
					</view>
				</view>
			</view>
			<view class="tab_nav">
				<view class="navTitle" v-for="(item,index) in navList" :key="index">
					<view :class="{'active':myAllindex === index}" @click="checked(index)">
						{{item.title}}
					</view>
				</view>
			</view>
		</view>
		<view class="" v-if="myAllindex == 0">
			<view class="flexleft flex_wrap">
				<view class="videobox flexcenter" v-for="item in myAll[0].list.data" :key="item.id" @click="shipin(item.id,item.user_id)">
					<image  :src="item.video_url_text+'?x-oss-process=video/snapshot,t_10000,m_fast'" mode=""></image>
					<view class="videocontent flexleft">
						<u-icon name="heart" color="#fff" size="15"></u-icon>
						<view class="xiaobai smalltext">{{item.dz_num}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-if="myAllindex == 1">
			<view class=" mainpadding2 ffffff" :class="index==0?'':'margin_top'" v-for="(item,index) in myAll[1].list.data"
				:key="item.id" @click="tzckxq(item.id)">
				<view class="flexleft">
					<image class="margin_right1 xiaotux" :src="item.user.avatar_text" mode=""></image>
					<view class="">
						<view class="ershiba xiaohei">{{item.user.nickname}}</view>
						<view class="smalltext xiaohui margin_top1">{{item.createtime_text}}</view>
					</view>
				</view>
				<view class="flexleft margin_top" v-if="dataAll.qwdx">
					<u-icon name="heart-fill" color="#ff0000" size="20"></u-icon>
					<view class=" sanshier xiaohei">期望<text v-if="qingshaonian!=1">对象</text>：{{dataAll.qwdx}}</view>
				</view>
				<view class="margin_top sanshier xiaohei">{{item.content}}</view>
				<view class="flexleft flex_wrap">
					<view class="sanshis flexcenter margin_top" v-for="(ite,index) in item.images_text" :key="index">
						<image class="dtbabb" :src="ite" mode=""></image>
					</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershiw flexcenter">
						<view class="flexleft">
							<view class="dticon">
								<image src="../static/image/system/s.png" mode=""></image>
							</view>
							<view class="smalltext xiaohei">{{item.zs_num}}</view>
						</view>
					</view>
					<view class="ershiw flexcenter">
						<view class="flexleft">
							<view class="dticon">
								<image src="../static/image/system/fx.png" mode=""></image>
							</view>
							<view class="smalltext xiaohei">{{item.share_num}}</view>
						</view>
					</view>
					<view class="ershiw flexcenter">
						<view class="flexleft">
							<view class="dticon">
								<image src="../static/image/system/xx.png" mode=""></image>
							</view>
							<view class="smalltext xiaohei">{{item.comment_num}}</view>
						</view>
					</view>
					<view class="ershiw flexcenter">
						<view class="flexleft">
							<view class="dticon">
								<image src="../static/image/system/dz.png" mode="" v-if="!item.is_dz"></image>
								<image src="../static/image/system/dzs.png" mode="" v-if="item.is_dz"></image>
							</view>
							<view class="smalltext xiaohei">{{item.dz_num}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				navList: [{
					index: 0,
					title: '作品'
				}, {
					index: 1,
					title: "动态"
				}],
				statusBarHeight: 0,
				op: 0,
				show: false,
				lhshow: false,
				listid: "",
				dataAll: {},
				pageShow: false,
				myAll: [{ //视频列表
						url: "/api/videocl/myVideoIndex",
						page: 1,
						list: {
							data: []
						}
					},
					{ //动态列表
						url: "/api/userdtcl/dtIndex",
						page: 1,
						list: {
							data: []
						}
					},
				],
				myAllindex: 0,
				user_id: "", //当前登录的用户id
				qingshaonian:1
			}
		},
		onLoad(options) {
			this.listid = options.id
			uni.getSystemInfo({
				success: (res) => {
					this.statusBarHeight = res.statusBarHeight
				}
			})
			this.getlistAll()
			// this.getisshow()
		},
		onShow() {
			this.qingshaonian = uni.getStorageSync("qingshaonian") || 0
			this.user_id = uni.getStorageSync("user_id")
			this.getDetail()
			this.init()
		},
		onPageScroll(res) {
			let top = res.scrollTop
			let height = this.statusBarHeight + 44
			if (top <= height) {
				this.op = Math.round(top / height * 100) / 100
			} else {
				this.op = 1
			}
		},
		methods: {
			sixin() {
				if (this.listid == this.user_id) { //如果当前主页的id是自己的话不走下面逻辑
					return false
				}
				let that = this
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/user/addFriends', 'GET', {
					firend_id:this.listid
				}).then(res => {
					uni.hideLoading()
					let data = {
						firend_id: this.listid,
						friend_name: this.dataAll.nickname,
						firend_avatar_text: this.dataAll.avatar_text
					}
					uni.navigateTo({
						url: "/pages_message/chat?msg=" + encodeURIComponent(JSON.stringify(data))
					})
				})
				
			},
			tzckxq(id) {
				uni.navigateTo({
					url: '/pages_fabu/dongtaixq?id=' + id
				})
			},
			shipin(id,userid){
				uni.navigateTo({
					url: "/pages_homepage/shipin/shipin?id="+id+"&userid="+userid
				})
			},
			getlistAll() {
				this.myAll.forEach((item, index) => {
					if (item.url) {
						this.init(index)
					}
				})
			},
			init(index, isPage, page) {
				let _this = this
				let url = this.myAll[index].url
				let data = {
					page: this.myAll[index].page || 1,
					limit: 12,
					user_id:this.listid
				}
				
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = this.myAll[index].list;
						if (isPage == true) {
							this.myAll[index].list.data = dataList.data.concat(resList.data);
						} else {
							this.myAll[index].list = res.data
							this.myAll[index].list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.myAll[this.myAllindex].list;
				let page = _this.myAll[this.myAllindex].page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.myAll[this.myAllindex].page = page;
				_this.init(this.myAllindex, true, page);
			},
			getDetail() {
				httpRequest.request('/api/index/userPage', 'GET', {
					id: this.listid,
				}).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			},
			guanzhufn(b_user_id, item) {
				httpRequest.request('/api/user/clUserGz', 'GET', {
					b_user_id
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						item.is_gz = 1
						let data = {
							is_gz:1,
							frienduser_id:b_user_id
						}
						uni.$emit("guanzhuemitfn",data)
					}
				})
			},
			cancelguanzhufn(b_user_id, item) {
				httpRequest.request('/api/user/clUserGz', 'GET', {
					b_user_id
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						item.is_gz = 0
						let data = {
							is_gz:0,
							frienduser_id:b_user_id
						}
						uni.$emit("guanzhuemitfn",data)
					}
				})
			},
			// 开起拉黑
			dklh() {
				this.show = false
				this.lhshow = true
			},
			jumper(url) {
				uni.navigateTo({
					url: url
				})
			},
			lhclose() {
				this.lhshow = false
			},
			lahei(b_user_id){
				this.show = false
				this.lhshow = false
				httpRequest.request('/api/user/clUserBack', 'GET', {
					b_user_id
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						this.getDetail()
						uni.$emit("laheifn","")
					}
				})
			},
			close() {
				this.show = false
				// console.log('close');
			},
			// 跳转关注及粉丝
			tzgywm(i) {
				let data = {
					type: i,
					id: this.listid,
					name: this.dataAll.nickname
				}
				uni.navigateTo({
					url: '/pages_homepage/guanzhu?msg=' + encodeURIComponent(JSON.stringify(data))
				})
			},
			checked(index) {
				if(index==this.myAllindex){
					return false
				}
				this.myAllindex = index
			},
			fhsyy() {
				uni.navigateBack(1)
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 视频盒子样式
	.videobox {
		position: relative;
		width: 33.33%;
		height: 350rpx;
		margin-top: 5rpx;

		image {
			width: 98%;
			height: 100%;
		}

		.videocontent {
			bottom: 0;
			left: 0;
			position: absolute;
			padding: 10rpx;
		}
	}

	// 视频盒子样式结束
	.wbox {
		padding: 25rpx;
		border-radius: 50%;
		background-color: #f2f2f2;
	}

	.nav {
		position: fixed;
		top: 0rpx;
		left: 0;
		right: 0;
		background: #fff;
		z-index: 1000;
	}

	.dticon {
		width: 32rpx;
		height: 32rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.dtbabb {
		width: 224rpx;
		height: 224rpx;
	}

	.xiaotux {
		width: 64rpx;
		height: 64rpx;
		border-radius: 50%;
	}

	.tab_nav {
		background-color: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
		padding-bottom: 11rpx;
	}

	.tab_nav .navTitle {
		height: 90rpx;
		line-height: 90rpx;
		width: 100%;
		text-align: center;
		font-size: 30rpx;
		font-weight: bold;
		color: #999999;
	}

	.active {
		font-size: 30rpx;
		color: #333333;
		font-weight: bold;
		position: relative;
	}

	.active::after {
		content: "";
		position: absolute;
		width: 36rpx;
		height: 6rpx;
		background: #000000;
		border-radius: 3rpx;
		background-size: 100% 100%;
		left: 0rpx;
		right: 0rpx;
		bottom: 0rpx;
		margin: auto;
	}

	.xhbtn {
		padding: 10rpx 20rpx;
		background: #F5F5F5;
		border-radius: 20rpx;
	}

	.zhixiang {
		width: 20rpx;
		height: 20rpx;
	}

	.fuzhi {
		width: 24rpx;
		height: 24rpx;
	}

	.xlbtn {
		padding: 5rpx 15rpx;
		height: 34rpx;
		border: 1rpx solid #2361FF;
	}

	.xhuibtn {
		padding: 5rpx 15rpx;
		height: 34rpx;
		border: 1rpx solid #999;
	}

	.dhbtn {
		background: #F5F5F5;
		border-radius: 44rpx;
		padding: 30rpx 68rpx;
	}

	.labtn {
		width: 256rpx;
		height: 88rpx;
		background: #2361FF;
		border-radius: 44rpx;
	}

	.touxiang {
		width: 192rpx;
		height: 192rpx;
		border-radius: 50%;
	}

	.zuytu {
		width: 100%;
		height: 300rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.dingbu {
		background-size: 100% 100%;
		width: 100%;
		position: absolute;
		top: 40rpx;
		padding: 30rpx;
		left: 0;
		box-sizing: border-box;
	}

	.baibox {
		background: #FFFFFF;
		border-radius: 40rpx 40rpx 0 0;
	}

	.dbicon {
		width: 48rpx;
		height: 48rpx;
	}

	// .dingbu {

	// 	padding: 88rpx 30rpx 130rpx;
	// 	background-size: 100% 100%;
	// 	width: 100%;
	// 	background-image: url('../static/image/system/zybjt.png');
	// 	box-sizing: border-box;
	// }
</style>